package com.chushouya.common.constant;

import com.general.framework.core.enums.IEnum;
import com.general.framework.core.lang.Strings;

import java.util.Objects;

/**
 * 配置类型
 * (0文本1 json对象 2json数组 3富文本 4数值)
 */
public enum ConfigTypeEnum  implements IEnum<Integer> {

    text(0, "文本"),
    jsonObject(1, "json对象"),
    jsonArray(2, "json数组"),
    richText(3, "富文本"),
    decimal(4, "小数"),
    integer(5, "整数");

    private Integer value;

    private String desc;

    ConfigTypeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String getDesc(Integer value) {
        for (ConfigTypeEnum thisEnum : ConfigTypeEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum.desc;
            }
        }
        return Strings.EMPTY;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.desc;
    }
}
